import xpMtgSDK from './services/mtgsdk/xpMtgSdk.umd'

function init() {
  wx.showLoading({ title: '加载中' });
  xpMtgSDK.init({
    appid: 'wxba522d97137e0a39',
    debug: 0,
  }, function (res) {
    xpMtgSDK.login({}, function (res) {
      wx.hideLoading()
      if (res.code > 0) {
        wx.showModal({
          title: '提示',
          content: res.msg,
        })
      }
    })
  })
}

App({
  onLaunch() {
    wx.onAppShow(function(res){
      let params = JSON.parse(JSON.stringify(res))
      xpMtgSDK.addLog(2001, 'onshow', params)
      if (res.path == 'pages/index/index') {
        init()
      }
    })
  }
})
